<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
		<title>后台管理-修改密码</title>
		<link rel="stylesheet" href="/resources/src/css/lib/bootstrap.min.css"/>
		<link rel="stylesheet" href="/resources/src/css/admin/main.css" />
    </head>
    <body>
		<article class="main">
			<div class="main-wrapper">
				<section class="content">
					<div class="container">
						<div class="con-header">
							<jsp:include page="../common/folderbar.jsp" />
						</div>
						<div class="con-body">
							<div class="input-row">
								<label for="#password"><span style="letter-spacing: 0.2px;">新&nbsp;&nbsp;密&nbsp;&nbsp;码：</span></label>
								<input type="password" id="password" name="password" placeholder="请输入新密码"/>
							</div>
							<div class="input-row">
								<label for="#rePassword"><span>确认密码：</span></label>
								<input type="password" id="rePassword" name="rePassword" placeholder="请再次输入新密码"/>
							</div>
							<div class="submit text-center">
								<p class="btn-text">
									<span>确认</span>
								</p>
							</div>
						</div>
					</div>
				</section>
			</div>
		</article>
		
		<script src="/resources/src/js/jquery-2.1.4.js"></script>
		<script src="/resources/src/js/jquery.nicescroll.js"></script>
		<script src="/resources/src/js/admin/main.js"></script>
		<script>
			$(function(){
				
				//动态验证
				$(".con-body").on("keyup","input",function(){
					var value=$(this).val().trim();
					var id=$(this).attr("id");
					
					if(id==="password"){
						if(value=="" || value==null){
							Global.showTip("#password","请输入新密码！");
						}
						else if(!Re.password.test(value)){
							Global.showTip("#password","密码格式错误！");
						}
						else{
							$(this).removeClass("errBorder");
							$("#password").parents(".input-row").next(".err").remove();
						}
					};
					
					if(id==="rePassword"){
						var passwords=$("#password").val().trim();
						if(value=="" || value==null){
							Global.showTip("#rePassword","请再次输入密码！");
						}
						else if(value!==passwords){
							Global.showTip("#rePassword","两次输入密码不一致！");
						}
						else{
							$(this).removeClass("errBorder");
							$("#rePassword").parents(".input-row").next(".err").remove();
						}
					};
				});
	
				//提交表单
				$(".submit").on("click",function(){
					var passwords=$("#password").val().trim();
					var rePassword=$("#rePassword").val().trim();
					var flag=true;
					
					if(passwords=="" || passwords==null){
						Global.showTip("#password","请输入新密码！");
						flag=false;
					}
					else if(!Re.password.test(passwords)){
						Global.showTip("#password","密码格式错误！");
						flag=false;
					};
					
					if(rePassword=="" || rePassword==null){
						Global.showTip("#rePassword","请再次输入密码！");
						flag=false;
					}
					else if(rePassword!==passwords){
						Global.showTip("#rePassword","两次输入密码不一致！");
						flag=false;
					}
					
					//如果通过验证，提交表单数据；否则提示出错。
					if(flag){
						//提交
						//do something
						
						//以下代码在ajax返回成功后执行
						var sucHTML="<i class='iconfont icon-jiuxu'></i>";
						Global.submitTip(".btn-text","turnSuccess",sucHTML);
					}else{
						//错误提示
						var errHTML="<i class='iconfont icon-cuowu'></i>";
						Global.submitTip(".btn-text","turnErr",errHTML);
					};
				});
				
			});
		</script>
 	</body>
</html>